From 0c28c2366fa37d5cd47010209f197e33a5865c70 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 14 Apr 2026 19:43:21 +0200 Subject: [PATCH] Prefer g_string_free_and_steal instead of g_string_free As that makes semantics clearer Part-of: --- src/gtkactionmuxer.c | 2 +- src/shell-perf-log.c | 4 ++-- src/st/croco/cr-additional-sel.c | 4 ++-- src/st/croco/cr-attr-sel.c | 2 +- src/st/croco/cr-declaration.c | 6 +++--- src/st/croco/cr-fonts.c | 2 +- src/st/croco/cr-parsing-location.c | 2 +- src/st/croco/cr-pseudo.c | 2 +- src/st/croco/cr-rgb.c | 2 +- src/st/croco/cr-selector.c | 2 +- src/st/croco/cr-simple-sel.c | 4 ++-- src/st/croco/cr-statement.c | 14 +++++++------- src/st/croco/cr-stylesheet.c | 2 +- src/st/croco/cr-term.c | 4 ++-- src/st/st-theme-node.c | 4 ++-- src/st/st-widget.c | 2 +- src/st/test-theme.c | 2 +- src/tray/na-tray-child.c | 2 +- 18 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/gtkactionmuxer.c b/src/gtkactionmuxer.c index ec0f20ee9..c361d6084 100644 --- a/src/gtkactionmuxer.c +++ b/src/gtkactionmuxer.c @@ -941,5 +941,5 @@ gtk_print_action_and_target (const gchar *action_namespace, g_string_append (result, action_name); - return g_string_free (result, FALSE); + return g_string_free_and_steal (result); } diff --git a/src/shell-perf-log.c b/src/shell-perf-log.c index 1de97f4fb..4848088e2 100644 --- a/src/shell-perf-log.c +++ b/src/shell-perf-log.c @@ -782,7 +782,7 @@ escape_quotes (const char *input) g_string_append_c (result, *p); } - return g_string_free (result, FALSE); + return g_string_free_and_steal (result); } static gboolean @@ -846,7 +846,7 @@ shell_perf_log_dump_events (ShellPerfLog *perf_log, g_string_append (output, " ]"); - return write_string (out, g_string_free (output, FALSE), error); + return write_string (out, g_string_free_and_steal (output), error); } typedef struct { diff --git a/src/st/croco/cr-additional-sel.c b/src/st/croco/cr-additional-sel.c index 9bd8d6a7d..f56a77f80 100644 --- a/src/st/croco/cr-additional-sel.c +++ b/src/st/croco/cr-additional-sel.c @@ -323,7 +323,7 @@ cr_additional_sel_to_string (CRAdditionalSel const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); str_buf = NULL; } @@ -421,7 +421,7 @@ cr_additional_sel_one_to_string (CRAdditionalSel const *a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); str_buf = NULL; } diff --git a/src/st/croco/cr-attr-sel.c b/src/st/croco/cr-attr-sel.c index e641e4ecb..627b2bc2f 100644 --- a/src/st/croco/cr-attr-sel.c +++ b/src/st/croco/cr-attr-sel.c @@ -168,7 +168,7 @@ cr_attr_sel_to_string (CRAttrSel const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); } return result; diff --git a/src/st/croco/cr-declaration.c b/src/st/croco/cr-declaration.c index 1917f62e7..8af67c383 100644 --- a/src/st/croco/cr-declaration.c +++ b/src/st/croco/cr-declaration.c @@ -539,7 +539,7 @@ cr_declaration_to_string (CRDeclaration const * a_this, gulong a_indent) } } if (stringue && stringue->str) { - result = g_string_free (stringue, FALSE); + result = g_string_free_and_steal (stringue); } return result; @@ -582,7 +582,7 @@ cr_declaration_list_to_string (CRDeclaration const * a_this, gulong a_indent) break; } if (stringue && stringue->str) { - result = (guchar *) g_string_free (stringue, FALSE); + result = (guchar *) g_string_free_and_steal (stringue); } return result; @@ -634,7 +634,7 @@ cr_declaration_list_to_string2 (CRDeclaration const * a_this, break; } if (stringue && stringue->str) { - result = (guchar *) g_string_free (stringue, FALSE); + result = (guchar *) g_string_free_and_steal (stringue); } return result; diff --git a/src/st/croco/cr-fonts.c b/src/st/croco/cr-fonts.c index da16cf883..e5bc964fc 100644 --- a/src/st/croco/cr-fonts.c +++ b/src/st/croco/cr-fonts.c @@ -196,7 +196,7 @@ cr_font_family_to_string (CRFontFamily const * a_this, &stringue); if (status == CR_OK && stringue) { - result = (guchar *) g_string_free (stringue, FALSE); + result = (guchar *) g_string_free_and_steal (stringue); stringue = NULL; } else { diff --git a/src/st/croco/cr-parsing-location.c b/src/st/croco/cr-parsing-location.c index 2b4097413..0414959ae 100644 --- a/src/st/croco/cr-parsing-location.c +++ b/src/st/croco/cr-parsing-location.c @@ -126,7 +126,7 @@ cr_parsing_location_to_string (CRParsingLocation const *a_this, a_this->byte_offset) ; } if (result->len) { - str = g_string_free (result, FALSE) ; + str = g_string_free_and_steal (result) ; } else { g_string_free (result, TRUE) ; } diff --git a/src/st/croco/cr-pseudo.c b/src/st/croco/cr-pseudo.c index f81f9a6e6..843e33abb 100644 --- a/src/st/croco/cr-pseudo.c +++ b/src/st/croco/cr-pseudo.c @@ -107,7 +107,7 @@ cr_pseudo_to_string (CRPseudo const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); str_buf = NULL; } diff --git a/src/st/croco/cr-rgb.c b/src/st/croco/cr-rgb.c index 4691e961c..7947450e6 100644 --- a/src/st/croco/cr-rgb.c +++ b/src/st/croco/cr-rgb.c @@ -273,7 +273,7 @@ cr_rgb_to_string (CRRgb const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); } return result; diff --git a/src/st/croco/cr-selector.c b/src/st/croco/cr-selector.c index 179391194..269af7f8e 100644 --- a/src/st/croco/cr-selector.c +++ b/src/st/croco/cr-selector.c @@ -157,7 +157,7 @@ cr_selector_to_string (CRSelector const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); str_buf = NULL; } diff --git a/src/st/croco/cr-simple-sel.c b/src/st/croco/cr-simple-sel.c index 07a53676c..03838b6da 100644 --- a/src/st/croco/cr-simple-sel.c +++ b/src/st/croco/cr-simple-sel.c @@ -152,7 +152,7 @@ cr_simple_sel_to_string (CRSimpleSel const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); str_buf = NULL; } @@ -193,7 +193,7 @@ cr_simple_sel_one_to_string (CRSimpleSel const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); str_buf = NULL; } diff --git a/src/st/croco/cr-statement.c b/src/st/croco/cr-statement.c index 0596eff53..7e404656a 100644 --- a/src/st/croco/cr-statement.c +++ b/src/st/croco/cr-statement.c @@ -622,7 +622,7 @@ cr_statement_ruleset_to_string (CRStatement const * a_this, glong a_indent) cr_utils_dump_n_chars2 (' ', stringue, a_indent); } g_string_append (stringue, "}"); - result = g_string_free (stringue, FALSE); + result = g_string_free_and_steal (stringue); g_clear_pointer (&tmp_str, g_free); return result; @@ -671,7 +671,7 @@ cr_statement_font_face_rule_to_string (CRStatement const * a_this, g_string_append (stringue, "\n}"); } if (stringue) { - result = g_string_free (stringue, FALSE); + result = g_string_free_and_steal (stringue); stringue = NULL ; } return result ; @@ -714,7 +714,7 @@ cr_statement_charset_to_string (CRStatement const *a_this, g_clear_pointer (&str, g_free); } if (stringue) { - str = g_string_free (stringue, FALSE); + str = g_string_free_and_steal (stringue); } return str ; } @@ -767,7 +767,7 @@ cr_statement_at_page_rule_to_string (CRStatement const *a_this, } g_string_append (stringue, "\n}\n"); } - result = g_string_free (stringue, FALSE) ; + result = g_string_free_and_steal (stringue) ; stringue = NULL ; return result ; } @@ -828,7 +828,7 @@ cr_statement_media_rule_to_string (CRStatement const *a_this, g_string_append (stringue, "\n}"); } if (stringue) { - str = g_string_free (stringue, FALSE) ; + str = g_string_free_and_steal (stringue) ; } return str ; } @@ -888,7 +888,7 @@ cr_statement_import_rule_to_string (CRStatement const *a_this, g_string_append (stringue, " ;"); } if (stringue) { - str = g_string_free (stringue, FALSE) ; + str = g_string_free_and_steal (stringue) ; stringue = NULL ; } return str ; @@ -2544,7 +2544,7 @@ cr_statement_list_to_string (CRStatement const *a_this, gulong a_indent) str = NULL ; } } - str = g_string_free (stringue, FALSE) ; + str = g_string_free_and_steal (stringue) ; return str ; } diff --git a/src/st/croco/cr-stylesheet.c b/src/st/croco/cr-stylesheet.c index 63e763feb..016daeb36 100644 --- a/src/st/croco/cr-stylesheet.c +++ b/src/st/croco/cr-stylesheet.c @@ -82,7 +82,7 @@ cr_stylesheet_to_string (CRStyleSheet const *a_this) } } if (stringue) { - str = g_string_free (stringue, FALSE) ; + str = g_string_free_and_steal (stringue) ; stringue = NULL ; } return str ; diff --git a/src/st/croco/cr-term.c b/src/st/croco/cr-term.c index 669594ecb..720293c81 100644 --- a/src/st/croco/cr-term.c +++ b/src/st/croco/cr-term.c @@ -462,7 +462,7 @@ cr_term_to_string (CRTerm const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); str_buf = NULL; } @@ -656,7 +656,7 @@ cr_term_one_to_string (CRTerm const * a_this) } if (str_buf) { - result = (guchar *) g_string_free (str_buf, FALSE); + result = (guchar *) g_string_free_and_steal (str_buf); str_buf = NULL; } diff --git a/src/st/st-theme-node.c b/src/st/st-theme-node.c index 7cfea44b8..8b8140f9e 100644 --- a/src/st/st-theme-node.c +++ b/src/st/st-theme-node.c @@ -2960,7 +2960,7 @@ font_family_from_terms (CRTerm *term, out: if (result) { - *family = g_string_free (family_string, FALSE); + *family = g_string_free_and_steal (family_string); return TRUE; } else @@ -4555,5 +4555,5 @@ st_theme_node_to_string (StThemeNode *node) g_string_append_c (desc, ']'); - return g_string_free (desc, FALSE); + return g_string_free_and_steal (desc); } diff --git a/src/st/st-widget.c b/src/st/st-widget.c index ea19043f5..72c7e8adc 100644 --- a/src/st/st-widget.c +++ b/src/st/st-widget.c @@ -2323,7 +2323,7 @@ st_describe_actor (ClutterActor *actor) g_string_append_c (desc, ']'); - return g_string_free (desc, FALSE); + return g_string_free_and_steal (desc); } /** diff --git a/src/st/test-theme.c b/src/st/test-theme.c index 51fa06108..56a410e33 100644 --- a/src/st/test-theme.c +++ b/src/st/test-theme.c @@ -100,7 +100,7 @@ text_decoration_to_string (StTextDecoration decoration) else g_string_append(result, "none"); - return g_string_free (result, FALSE); + return g_string_free_and_steal (result); } static void diff --git a/src/tray/na-tray-child.c b/src/tray/na-tray-child.c index 9ec667033..0d445a7d5 100644 --- a/src/tray/na-tray-child.c +++ b/src/tray/na-tray-child.c @@ -149,7 +149,7 @@ latin1_to_utf8 (const char *latin1) ++p; } - return g_string_free (str, FALSE); + return g_string_free_and_steal (str); } /* derived from libwnck/xutils.c, comes as LGPLv2+ */ -- 2.39.5